package com.lingjtx.iot.network.common;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@ConfigurationProperties(prefix = "mqtt")
public class MqttPropertiesEntity {

    private String brokerUrl = "tcp://localhost:1883";
    private String username = "test";
    private String password = "test123456";
    private int timeout = 15;  // 设置合理超时连接（单位秒）
    private int keepAlive = 60;
    private int maxInflight = 3;
    private int maxReconnectDelay = 20000; // 建议控制在 10~30 秒之间
    private int qos = 1;
    private String groupId = "defaultGroup";
    private RetryConfig retry = new RetryConfig();

    @Data
    @ConfigurationProperties(prefix = "mqtt.retry")
    public static class RetryConfig {
        private int maxAttempts = 3;
        private long initialInterval = 1000;
        private double multiplier = 2;
        private long maxInterval = 10000;
    }
}
